<!DOCTYPE html>

<html>
<head>
    <title>Beego</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script>
        var h2fUrl = "http://jenkins.silcs.net:9090/api/v1/data/syn/Hangzhou2Frankfurt?deviceId="
        var r2dUrl = "http://jenkins.silcs.net:9090/api/v1/data/syn/real2dev?deviceId="

        var mv2FrkUrl = "http://jenkins.silcs.net:9090/api/v1/dispatch/cn2eu?deviceId="
        var mv2DevUrl = "http://jenkins.silcs.net:9090/api/v1/dispatch/cn2dev?deviceId="
        var mvF2HUrl = "http://jenkins.silcs.net:9090/api/v1/dispatch/eu2cn?deviceId="
        var mvDev2RealUrl = "http://jenkins.silcs.net:9090/api/v1/dispatch/dev2cn?deviceId="
        var delRomUrl = "http://jenkins.silcs.net:9090/api/v1/romversion/delete?romVer="
        var xhr;

        function mv2Frk() {
            var imputEle = document.getElementById("deviceId");
            let deviceId = imputEle.value;
            if (deviceId == "") {
                window.alert("设备号不可为空")
                return
            }
            xhr = new XMLHttpRequest();
            xhr.onreadystatechange = state_Change;
            xhr.open("GET", mv2FrkUrl + deviceId, true)
            xhr.send();
        }

        function mv2Dev() {
            var imputEle = document.getElementById("deviceId");
            let deviceId = imputEle.value;
            if (deviceId == "") {
                window.alert("设备号不可为空")
                return
            }
            xhr = new XMLHttpRequest();
            xhr.onreadystatechange = state_Change;
            xhr.open("GET", mv2DevUrl + deviceId, true)
            xhr.send();
        }

        function mvF2H() {
            var imputEle = document.getElementById("deviceId");
            let deviceId = imputEle.value;
            if (deviceId == "") {
                window.alert("设备号不可为空")
                return
            }
            xhr = new XMLHttpRequest();
            xhr.onreadystatechange = state_Change;
            xhr.open("GET", mvF2HUrl + deviceId, true)
            xhr.send();
        }

        function mvDev2Real() {
            var imputEle = document.getElementById("deviceId");
            let deviceId = imputEle.value;
            if (deviceId == "") {
                window.alert("设备号不可为空")
                return
            }
            xhr = new XMLHttpRequest();
            xhr.onreadystatechange = state_Change;
            xhr.open("GET", mvDev2RealUrl + deviceId, true)
            xhr.send();
        }

        function h2f() {
            var imputEle = document.getElementById("deviceId");
            let deviceId = imputEle.value;
            if (deviceId == "") {
                window.alert("设备号不可为空")
                return
            }
            xhr = new XMLHttpRequest();
            xhr.onreadystatechange = state_Change;
            xhr.open("GET", h2fUrl + deviceId, true)
            xhr.send();
        }

        function r2d() {
            var imputEle = document.getElementById("deviceId");
            let deviceId = imputEle.value;
            if (deviceId == "") {
                window.alert("设备号不可为空")
                return
            }
            xhr = new XMLHttpRequest();
            xhr.onreadystatechange = state_Change;
            xhr.open("GET", r2dUrl + deviceId, true)
            xhr.send();
        }

        /**
         * 删除固件版本号
         */
        function delRom() {
            var imputEle = document.getElementById("romVer");
            let romVer = imputEle.value;
            if (romVer == "") {
                window.alert("固件版本号为空")
                return
            }
            var msg = "确定要删除固件[" + romVer + "]吗？"
            if (confirm(msg) == true) {
                console.log("做删除操作")
                xhr = new XMLHttpRequest();
                xhr.onreadystatechange = state_Change;
                xhr.open("GET", delRomUrl + romVer, true)
                xhr.send();
            } else {
                console.log("删除终止")
            }
        }

        function state_Change() {
            if (xhr.readyState == 4) {// 4 = "loaded"
                if (xhr.status == 200) {// 200 = OK
                    alert(xhr.responseText)
                } else {
                    alert("error");
                }
            }
        }

    </script>
</head>
<body>
<header class="hero-unit" style="background-color:#A9F16C">
    <div class="container">
        <div class="row">
            <div class="hero-text">
                <h1>欢迎来到雎鸠!</h1>
                <h2>快捷导航</h2>
                <p class="description">
                    <a href="http://172.18.2.134:8080/swagger-ui.html#/dispatch-controller" target="_blank">调度地址-国外</a>
                </p>
                <p class="description">
                    <a href="http://10.18.0.78:8080/swagger-ui.html#/dispatch-controller" target="_blank">调度地址-国内</a>
                </p>
                <p class="description">
                    <a href="http://10.28.8.243:8080/swagger-ui.html#/dispatch-controller" target="_blank">调度地址-测试</a>
                </p>
                <h2>功能列表</h2>
                <!--
                <h3>1.数据同步</h3>
                <p>
                    <button onclick="h2f()">数据同步-国内2海外</button>
                </p>
                <p>
                    <button onclick="r2d()">数据同步-国内2测试</button>
                </p>
                -->
                <h3>1.设备调度</h3>
                <p>
                    <input id="deviceId" type="text" placeholder="请输入设备号">
                </p>
                <p>
                    <button onclick="mv2Frk()">调度-国内到海外</button>
                </p>
                <p>
                    <button onclick="mv2Dev()">调度-正式到测试</button>
                </p>
                <p>
                    <button onclick="mvF2H()">调度-海外到国内</button>
                </p>
                <p>
                    <button onclick="mvDev2Real()">调度-测试到正式</button>
                </p>
                <h3>2.删除固件版本</h3>
                <p>
                    <input id="romVer" type="text" placeholder="请输入固件版本号">
                    <button onclick="delRom()">删除</button>
                </p>
            </div>
        </div>
    </div>
</header>
</body>
</html>